package com.ssfeng.youxia.zk;

import utils.SensitivewordFilter;

/**
 * Created by liyuhang on 2019-09-21.
 */
public class Constants {

    public static String DB_DRIVE = "";

    public static String DB_URL = "";

    public static String DB_USER = "";

    public static String DB_PASSWORD = "";

    public static String DB_POOL_MAXACTIVE = "";

    public static String DB_POOL_MINIDLE = "";

    public static String SENSITIVE_WORD = "";


    static {

        try {
            ZkClient zkClient = ZkClient.getInstance();
            DB_DRIVE = zkClient.getProperty("db","db.driver");
            DB_URL = zkClient.getProperty("db","db.url");
            DB_USER = zkClient.getProperty("db", "db.user");
            DB_PASSWORD = zkClient.getProperty("db", "db.password");
            DB_POOL_MAXACTIVE = zkClient.getProperty("db", "db.pool.maxActive");
            DB_POOL_MINIDLE = zkClient.getProperty("db", "db.pool.minIdle");
            SENSITIVE_WORD = zkClient.getProperty("", "");
        } catch (Exception e) {

        }



        ZkClient.getInstance().addPropertyListener("db", "db.driver", new ChangeListener() {
            @Override
            public void getData(String data) {
                Constants.DB_DRIVE = data;
            }
        });

        ZkClient.getInstance().addPropertyListener("", "", new ChangeListener() {
            @Override
            public void getData(String data) {
                Constants.SENSITIVE_WORD = data;
                SensitivewordFilter.getInstance().addSensitiveWordToHashMap();
            }
        });
    }

}
